package com.eascs.o2o.common.controller;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.common.util.ExceptionUtil;
import com.eascs.o2o.common.exception.NoAccessException;
import com.eascs.site.view.ViewContext;

public abstract class BaseViewController extends com.eascs.site.controller.BaseViewController {

	private final Logger logger = LoggerFactory.getLogger(BaseViewController.class);
	
	@ExceptionHandler
	@ResponseStatus(HttpStatus.UNAUTHORIZED)
	public String noPermissionException(NoAccessException noAccessException) {
		logger.info(noAccessException.getMessage(), noAccessException);
		ViewContext.put("exceptionMessage", "您无权限访问该页面");
		ViewContext.put("exceptionStakTrace", ExceptionUtil.stackTrace(noAccessException));
		return "/uc/login";
	}
}